<?php
namespace App\Http\Controllers\Admin\Platform;

use App\Service\Admin\Platform\ItemUserService;
use Illuminate\Http\Request;

class ItemUserController extends BaseController
{
    //项目用户

    public function __construct(ItemUserService $service)
    {
        $this->db = $service;
    }

    //列表
    public function index(Request $request)
    {
        $token = $request->post('token', '');
        $uid = $this->db->getUidByToken($token);
        if (!$uid) {
            return $this->toJson(-2, '没有登录');
        }
        $pas['type_id'] = $request->post('type_id', 0);
        $pas['cate_id'] = $request->post('cate_id', 0);
        $pages['start'] = $request->post('page', 1);
        $pages['limit'] = $request->post('limit', 10);
        $res = $this->db->index($pas, $pages);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }
}